﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VINETLIFE.DO;
using VINETLIFE.BL;
using System.Data;

namespace VINETLIFE.Module
{
    public partial class ucHomeSlide : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                rptMainSlideDataSource();
            }
            //{
            //    rptSetTopProductDataSource();
            //    rptHomeSlideDataSource();
            //}
        }
        protected void rptMainSlideDataSource()
        {
            rptMainSlide.DataSource = new SlideBL().SelectByCategoryID(1);
            rptMainSlide.DataBind();
        }
        //protected void rptSetTopProductDataSource()
        //{
        //    rptSetTopProduct.DataSource = new cmsProductBL().SelectFrontPage(1, -1, -1, -1, 1);
        //    rptSetTopProduct.DataBind();
        //}

        //protected void rptHomeSlideDataSource()
        //{
        //    DataTable dtSlide = new cmsProductBL().SelectFrontPage(1, -1, -1, -1, 1);
        //    if (dtSlide.Rows.Count <= 0)
        //    {
        //        divMulti.Visible = false;
        //        divFull.Visible = true;
        //        // Không có khuyến mãi
        //        rptFull.DataSource = new SlideBL().SelectByCategoryID(0);
        //        rptFull.DataBind();
        //        ltrStyleMain.Text = " <style type='text/css'> .main-img{display:none;position:absolute;top:0;left:0;z-index:0;border:0px;width: 960px;height: 440px;}</style>";
        //    }
        //    else
        //    {
        //        divFull.Visible = false;
        //        divMulti.Visible = true;
        //        //Có khuyến mãi
        //        DateTime timeCountDown = new DateTime();
        //        timeCountDown = (DateTime)dtSlide.Rows[0]["PromotionEndDate"];
        //        lblCountDown.Text = "<script type='text/javascript'>$(function () {var austDay = new Date();austDay = new Date(" + timeCountDown.Year + "," + (timeCountDown.Month - 1) + "," + timeCountDown.Day + "," + timeCountDown.Hour + "," + timeCountDown.Minute + "," + timeCountDown.Second + ");$('#defaultCountdown').countdown({ until: austDay, format: 'HMS',compact: true,description: ''});$('#year').text(austDay.getFullYear());});</script>";
              
        //        rptMainHomeSlide.DataSource = new SlideBL().SelectByCategoryID(1);
        //        rptMainHomeSlide.DataBind();
        //        ltrStyleMain.Text = " <style type='text/css'> .main-img{display:none;position:absolute;top:0;left:0;z-index:0;border:0px;width: 690px;height: 440px;}</style>";
        //    }
           
        //}

        protected string FriendlyUrl(string s)
        {
            return Ultility.Change_AV(s);
        }
    }
}